/**
物资管理接口
 **/
import { http } from "@/utils/http";

// 物资管理-table接口返回
type ResultTable = {
  total?: number;
  data?: Array<any>;
};
/**
 *
 * @param data 左侧树形接口
 * @returns
 */

// 物资管理树形搜索接口
export const searchTreeMaterial = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/type/queryTree", {
    data
  });
};
// 物资管理树形新增接口
export const addTreeMaterial = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/type/create", {
    data
  });
};
// 物资管理树形修改接口
export const editTreeMaterial = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/type/update", {
    data
  });
};
// 物资管理树形删除接口
export const deleteTreeMaterial = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/type/delete", {
    data
  });
};
// 设备列表-获取设备二维码文件
export const getEqpImgs = data => {
  return http.request("post", "/erc/api/v1/material/queryFileIds", {
    data
  });
};

/**
 *
 * @param data 右侧表格接口
 * @returns
 */
/**
 物资管理-物资种类管理接口
 **/
// 查询设备台账列表接口
export const queryToolMaterial = (data?: object) => {
  return http.request<ResultTable>("post", "/erc/api/v1/material/queryList", {
    data
  });
};

// 新增物资种类接口
export const addToolMaterial = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/create", {
    data
  });
};

// 编辑物资种类数据接口
export const editToolMaterial = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/update", {
    data
  });
};

// 删除物资种类接口
export const deleteToolMaterial = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/delete", {
    data
  });
};

//设备位置查询接口
export const positionMaterial = (data?: object) => {
  return http.request<ResultTable>("post", "/erc/api/v1/position/queryTree", { data });
};

//备件管理接口
//查询关联备件列表
export const querySparePartByType = (data?: object) => {
  return http.request("post", "/erc/api/v1/eqp/querySparePartByType", {
    data
  });
};
// 查询设备关联备件列表
export const querySparePartByEqpId = (data?: object) => {
  return http.request("post", "/erc/api/v1/eqp/querySparePartByEqpId", {
    data
  });
};
//生成设备编号
export const getEqpId = (data?: Record<string, any>) => {
  return http.request("get", "/erc/api/v1/eqp/getEqpId", {
    data
  });
};

/**
 物资入库接口
 **/
// 物资入库--物资入库列表
export const queryMaterialList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/queryList", {
    data
  });
};
//查询物资入库审核列表
export const queryInApproveList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/inApprove/queryList", {
    data
  });
};
//查询补充采购单号
export const updatePurchaseList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/updatePurchase", {
    data
  });
};
//生成入库单号
export const getInNum = (data?: object) => {
  return http.request("get", "/erc/api/v1/material/in/getInNum", {
    data
  });
};
//查询入库清单列表
export const querynInventoryList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/inInventory/queryList", {
    data
  });
};
//物资类型下拉
export const queryMaterialTypeList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/type/queryTree", {
    data
  });
};
// 关联物资列表
export const queryMaterialTableList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/queryList", {
    data
  });
};
// 物资供应商下拉框列表
export const querySupplierList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/supplier/queryOptionList", {
    data
  });
};
//新增物资
export const materialInCreate = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/create", {
    data
  });
};
//删除物资入库
export const materialInDelete = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/delete", {
    data
  });
};
//编辑物资
export const materialInEdit = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/update", {
    data
  });
};
//查看物资
export const materialInView = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/queryList", {
    data
  });
};
//物资审核
export const CheckinApprovel = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/inApprove/approval", {
    data
  });
};
//物资转审
export const ToCheckinApprovel = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/inApprove/transfer", {
    data
  });
};
//根据名称模糊查询物资种类台账详情
export const likeByName = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/likeByName", {
    data
  });
};

/**
 物资管理-物资供应商接口
 **/
// 物资供应商接口
export const queryMaterialSupplier = (data?: object) => {
  return http.request<ResultTable>("post", "/erc/api/v1/material/supplier/queryList", {
    data
  });
};
// 新增物资供应商接口
export const addMaterialSupplier = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/supplier/create", {
    data
  });
};
// 修改物资供应商接口
export const updateMaterialSupplier = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/supplier/update", {
    data
  });
};
// 启用/禁用
export const ableType = (data?: Record<string, any>) => {
  return http.request("post", "/erc/api/v1/material/supplier/setUsedStatus", { data });
};
// 删除物资供应商接口
export const deleteMaterialSupplier = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/supplier/delete", {
    data
  });
};

/**
 * 物资出库接口
 */
//物资出库列表
export const materialOutQueryList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/out/queryList", {
    data
  });
};
//物资出库新增
export const materialOutCreate = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/out/create", {
    data
  });
};
//查询物资出库审核列表
export const outApproveQueryList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/outApprove/queryList", {
    data
  });
};
//生成出库单号
export const OutInNum = (data?: object) => {
  return http.request("get", "/erc/api/v1/material/out/getOutNum", {
    data
  });
};
//查询物资出库清单列表-回显使用
export const outInventoryQueryList = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/outInventory/queryList", {
    data
  });
};
//根据物资编码查询入库清单下拉列表
export const queryListByMaterialCode = (data?: any) => {
  return http.request<any[]>("post", "/erc/api/v1/material/inInventory/queryListByMaterialCode", {
    data
  });
};
//物资出库编辑
export const materialOutEdit = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/out/update", {
    data
  });
};
//删除物资出库
export const materialOutDelete = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/out/delete", {
    data
  });
};
//物资出库审批
export const outApproveApproval = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/outApprove/approval", {
    data
  });
};
//物资出库转审
export const outApproveTransfer = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/outApprove/transfer", {
    data
  });
};

/**
 * 物资台账接口
 */
//物资种类台账详情
export const queryByMaterialCode = (params?: Record<string, any>) => {
  return http.request("get", "/erc/api/v1/material/queryByMaterialCode", {
    params
  });
};
//根据物资编码查询入库列表
export const queryByMaterialCodeListIn = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/queryByMaterialCode", {
    data
  });
};
//根据物资编码查询出库列表
export const queryByMaterialCodeListOut = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/out/queryByMaterialCode", {
    data
  });
};
//物资入库详情
export const queryByInNum = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/in/queryByInNum", {
    data
  });
};
//根据物资编码查询出库列表
export const queryByOutNum = (data?: object) => {
  return http.request("post", "/erc/api/v1/material/out/queryByOutNum", {
    data
  });
};

//根据岗位ID获取用户信息接口
export const userQueryByPosition = (data?: object) => {
  return http.request<Array<any>>("post", "/account/api/v1/user/queryByPosition", {
    data
  });
};
// 物资种类-种类标签批量生成二维码文件
export const batchCreateEqpImgs = (data?: object) => {
  return http.request("post", "/erc/api/v1/materialQrCode/create", {
    data
  });
};
